package com.ho1ho.springboot.framework.core.controllers;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.servlet.resource.ResourceUrlProvider;

// https://www.mscharhag.com/spring/resource-versioning-with-spring-mvc
// http://www.voidcn.com/article/p-ehohwlcg-bqy.html
// http://www.360doc.com/content/16/0721/22/834950_577402671.shtml
// See also: <code>public ResourceUrlEncodingFilter resourceUrlEncodingFilter()</code> in concrete WebServerApplication
// Examples:
// <link rel="stylesheet" th:href="${@mvcResourceUrlProvider.getForLookupPath('/css/font.css')}" />
// <link rel="stylesheet" th:href="${urls.getForLookupPath('/css/style.css')}" />
@ControllerAdvice
public class ResourceUrlAdvice {

	@Resource
	ResourceUrlProvider resourceUrlProvider;

	@ModelAttribute("urls")
	public ResourceUrlProvider urls() {
		return this.resourceUrlProvider;
	}
}